package org.sean.generator.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.sean.generator.dto.DataSource;
import org.sean.generator.dto.DataSourceQuery;
import org.sean.generator.entity.DataSourceEntity;
import org.sean.generator.mapper.DataSourceMapper;
import org.sean.generator.service.DataSourceService;
import org.sean.framework.bean.PageQuery;
import org.sean.framework.service.impl.CrudServiceImpl;
import org.sean.framework.util.ObjectUtil;
import org.springframework.stereotype.Service;

/**
 * 
 *
 * @author Coder Generator
 */
@Service("dataSourceService")
public class DataSourceServiceImpl extends CrudServiceImpl<DataSourceMapper, DataSourceEntity, DataSource, DataSourceQuery>
        implements DataSourceService {

    /**
     * <pre>
     * 查询条件
     * 只适用于一下方法
     * {@link CrudServiceImpl#listDTO(PageQuery)} (PageQuery) }
     * {@link CrudServiceImpl#pageDTO(PageQuery)}
     * </pre>
     *
     * @param query 条件
     * @return 查询结果
     */
    @Override
    protected Wrapper<DataSourceEntity> getWrapper(DataSourceQuery query) {
        LambdaQueryWrapper<DataSourceEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ObjectUtil.isNotEmpty(query.getId()), DataSourceEntity::getId, query.getId());
        return wrapper;
    }

}
